﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SYH.User.BLL
{
    public class UserSimplyInfo
    {
        private static readonly SYH.User.DAL.UserSimplyInfo dal = new DAL.UserSimplyInfo();


        #region 前台方法
        #region 增
        /// <summary>
        /// 新增会员
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public static int AddUser(Model.UserSimplyInfo Model)
        {

            return dal.AddUser(Model);
        }
        #endregion

        #region  查
        /// <summary>
        /// GetModel
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public static Model.UserSimplyInfo GetModel(int Id)
        {
            
            return dal.GetModel( Id);
        }
        #endregion

        #region 根据主键ID获取某一字段
        /// <summary>
        /// 根据主键ID获取某一字段
        /// </summary>
        /// <param name="id">主键id</param>
        /// <param name="fieldName">字段</param>
        public static object GetOneFieldValueById(int id, string fieldName)
        {
           
            return dal.GetOneFieldValueById( id,  fieldName);
        }
        #endregion

        #region 根据条件更新多个字段
        /// <summary>
        /// 根据条件更新多个字段
        /// </summary>
        /// <param name="cols">字段列表 以,分隔</param>
        /// <param name="values">字段值列表 以,分隔;与字段对应</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public static int UpdateFields(string[] cols, object[] values, string where)
        {

            return dal.UpdateFields(cols, values, where);
        }
        #endregion

        #region 修改密码
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="OldPwd"></param>
        /// <param name="NewPwd"></param>
        /// <returns>0:旧密码不正确 1:成功 -1:失败</returns>
        public static int UpdatePassword(int UserId, string OldPwd, string NewPwd)
        {
           
            return dal.UpdatePassword( UserId,  OldPwd,  NewPwd);
        }
        #endregion


        #region 根据用户名查找用户数
        /// <summary>
        /// 根据用户名查找用户数
        /// </summary>
        /// <param name="Name"></param>
        /// <returns></returns>
        public static bool CheckUserExist(string Name)
        {
            return dal.CheckUserExist( Name)==1;
        }
        #endregion


        #region 根据邮箱是否已经使用
        /// <summary>
        /// 根据邮箱是否已经使用
        /// </summary>
        /// <param name="Email"></param>
        /// <returns></returns>
        public static bool CheckEmailExist(string Email)
        {
            return dal.CheckEmailExist(Email)>0;
        }
        #endregion

        #region 登录验证
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="Name">帐号</param>
        /// <param name="Password">密码</param>
        /// <returns></returns>
        public static Model.UserSimplyInfo CheckLogin(string Name, string Password)
        {
            return dal.CheckLogin(Name, Password);
        }
        #endregion


        #region 当天是否存在该IP
        /// <summary>
        /// 当天是否存在该IP
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        public static bool IfExistIpToday(string ip)
        {
            return dal.IfExistIpToday(ip);
        }
        #endregion
#endregion


    }
}
